package com.joeone.handler;

import com.joeone.bean.CommonResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;

/**
* @author 郑伟杰
* 描述：全局异常处理器
* 创建时间 2024/3/22 13:40
*/
@ControllerAdvice
public class GlobalExceptionHandler {
    private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
    /**
    * 功能：controller处理Exception异常
    */
    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public CommonResult exceptionHandler(HttpServletRequest httpServletRequest, Exception e) {
        logger.info("九牧王系统接口异常:", e);
        return CommonResult.error("系统接口异常");
    }
}
